# polls/models.py
from django.db import models


class Question(models.Model):
    question_text = models.CharField(
        max_length=200,
        verbose_name="问题描述"
    )
    pub_date = models.DateTimeField(
        verbose_name="发布时间",
        auto_now_add=True  # 自动记录创建时间
    )

    def __str__(self):
        return self.question_text


class Choice(models.Model):
    question = models.ForeignKey(
        Question,
        on_delete=models.CASCADE,
        related_name="choices",
        verbose_name="关联问题"
    )
    choice_text = models.CharField(
        max_length=200,
        verbose_name="选项内容"
    )
    votes = models.IntegerField(
        default=0,
        verbose_name="得票数"
    )

    def __str__(self):
        return f"{self.choice_text} (票数: {self.votes})"


from django.db import models

# Create your models here.
